<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags" %>
<%@taglib prefix="display" uri="http://displaytag.sf.net" %>
<%@taglib prefix="sx" uri="/struts-dojo-tags" %>
<%
	String contextPath = request.getContextPath();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="style/store.css" rel="stylesheet" type="text/css">
<link href="style/displaytagex.css" rel="stylesheet" type="text/css">
<title></title>
<script type="text/javascript">
	function onLoadInit(){
		document.getElementById("productname").focus();
	}
</script>
</head>
<body onload="onLoadInit();" >
<br/>
	<s:form name="formName" method="post" >
	<s:hidden name="dispMode" />
	<s:hidden name="product.prodId" />
	<table align="center">
		<tr><td>
			<span class="error" >
				<s:actionerror/>
				<s:actionmessage/>
			</span>
		</td></tr>
	</table>
	<s:if test="#request.dispMode == 1">
	<table border="1" align="center">
		<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td colspan="2" align="center">Add Product</td>
		</tr>
		<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td>Category:</td>
			<td><s:select name="c_id" 
							headerKey="0"
							headerValue="-SELECT-"
			                list="#request.categoryList" 
			                listKey="c_id" 
			                listValue="c_name"
			               />
			</td>
		</tr>
		<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td><label>Product Name: </label></td>
			<td><s:textfield name="product.name" id="productname" label="Product Name" ></s:textfield></td>
		</tr>
		<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td><label>Product Information: </label></td>
			<td><s:textfield name="product.information" id="information" label="Product Information" ></s:textfield></td>
		</tr>
		<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td><label>Product Price: </label></td>
			<td><s:textfield name="product.price" label="Product Price" ></s:textfield></td>
		</tr>
		<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td><label>Barcode: </label></td>
			<td><s:textfield name="product.barcode" /></td> 
		</tr>
		
		
		
		<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td><label>ExpiryDate: </label></td>
			<td><sx:datetimepicker name="product.expiryDate" id="startExpiryDate" displayFormat="MM/dd/yyyy" 
					type="date"/></td> 
		</tr>
		
		<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td><label>Stock Available: </label></td>
			<td><s:textfield name="product.quantity" /></td> 
		</tr>
		
		<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td><label>Unit: </label></td>
			<td><s:textfield name="product.unit" /></td> 
		</tr>
		
		
		<tr style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td colspan="2" ><s:submit cssClass="button" action="addProductAction" value="Add"></s:submit> </td>
		</tr>
	</table>
	<table align="center" >
		<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td><s:textfield name="queryString" /></td>
			<td><s:submit cssClass="button" action="productMaintenanceSearch" value="Search"></s:submit></td>
		</tr>
	</table>
	</s:if>
	<s:if test="#request.dispMode == 2">
		<table border="1" align="center">
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td colspan="2" align="center">Update Product</td>
			</tr>
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td>Category:</td>
			<td><s:select name="c_id" 
							headerKey="0"
							headerValue="-SELECT-"
			                list="#request.categoryList" 
			                listKey="c_id" 
			                listValue="c_name"
			               />
			</td>
		</tr>
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td><label>Product Name: </label></td>
				<td><s:textfield name="product.name" label="Product Name" ></s:textfield></td>
			</tr>
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td><label>Product Information: </label></td>
				<td><s:textfield name="product.information" id="information" label="Product Information" ></s:textfield></td>
			</tr>
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td><label>Product Price: </label></td>
				<td><s:textfield name="product.price" label="Product Price" ></s:textfield></td>
			</tr>
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td><label>Barcode: </label></td>
				<td><s:textfield name="product.barcode" /></td> 
			</tr>
			
			
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td><label>ExpiryDate: </label></td>
				<td><sx:datetimepicker name="product.expiryDate" id="startExpiryDate" displayFormat="MM/dd/yyyy" 
						type="date"/></td> 
			</tr>
			
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td><label>Stock Available: </label></td>
				<td><s:textfield name="product.quantity" /></td> 
			</tr>
			
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td><label>Unit: </label></td>
				<td><s:textfield name="product.unit" /></td> 
			</tr>
			
			
			<tr style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td colspan="2" ><s:submit cssClass="button" action="updateProductAction" value="Update"></s:submit> </td>
			</tr>
		</table>
	</s:if>
	</s:form>
	<s:if test="#request.dispMode == 1">
	<br/>
	<center>
	<s:set name="productList" value="productList" scope="request"></s:set>
	<display:table name="productList" uid="row" pagesize="10" class="dataTable"
	requestURI="goToProductMaintenance.action">
		<display:column property="prodId" title="ID"></display:column>
		<display:column property="barcode" title="Barcode"></display:column>
		<display:column property="name" title="Product Name" sortable="true"></display:column>
		<display:column property="category.c_name" title="Product Category" sortable="true"></display:column>
		<display:column property="information" title="Information"></display:column>
		<display:column property="price" title="Price"></display:column>
		<display:column>
			<s:url id="update" action="goToUpdateProductAction">
						<s:param name="product.prodId" value="#attr.row.prodId"></s:param>
					</s:url>
					<s:a href="%{update}">Update</s:a>
					&nbsp; | &nbsp;
					<s:url id="delete" action="deleteProductAction">
						<s:param name="product.prodId" value="#attr.row.prodId"></s:param>
					</s:url>
					<s:a href="%{delete}" onclick="return confirm('Are you sure?')" >Delete</s:a>
		</display:column>
		<display:setProperty name="paging.banner.placement" value="bottom" />
	</display:table>
	</center>
	</s:if>
	
</body>
</html>